<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/address.css')}}">
    <script src="{{mix('/js/web/user/address.js')}}"></script>
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.member_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="bm_myaddress" id="bm_add" add_update="0">
                    <div class="m_myaddress">
                        <h2 class="title title_add">新增收货地址</h2>
                        <form action="{{$request_url}}" id="address_info" method="post">
                            @if(isset($type) && $type == 'put')
                                {{method_field("PUT")}}
                            @endif
                            {!!  csrf_field() !!}
                            <input type="hidden" name="addr_id" value="{{old('area_code')}}" />
                            <input type="hidden" name="area_code" value="{{old('area_code')}}" />
                            <input type="hidden" name="province_code" value="{{old('province_code')}}" />
                            <input type="hidden" name="city_code" value="{{old('city_code')}}" />
                            <input type="hidden" id="address_head" name="address_head" value="{{old('address_head')}}" />
                            <div class="itembox">
                                <div class="item first clearfix">
                                    <span class="item-label f-lh36"><i>*</i>所在地区</span>
                                    @include('web.layout.city')
                                    @if($errors->has('area_code'))
                                        <p class="jm_error fl">{{$errors->first('area_code')}}</p>
                                    @else
                                        <p class="jm_error fl"></p>
                                    @endif
                                </div>
                                <div class="item clearfix">
                                    <span class="item-label f-lh36"><i>*</i>详细地址</span>
                                    <textarea name="address" class="item-textarea submit_val" autocomplete="off" placeholder="无需重复填写省市区，小于75个字">{{old('address')}}</textarea>
                                    @if($errors->has('address'))
                                        <p class="jm_error fl">{{$errors->first('address')}}</p>
                                    @else
                                        <p class="jm_error fl"></p>
                                    @endif
                                </div>
                                <div class="item item-fullname clearfix">
                                    <span class="item-label f-lh36"><i>*</i>收货人</span>
                                    <input type="text" value="{{old('receiver')}}" name="receiver" class="item-input item-input-fullname submit_val" placeholder="不能为昵称、X先生、X小姐等，请使用真实姓名,小于20字符" autocomplete="off">
                                    @if($errors->has('receiver'))
                                        <p class="jm_error fl">{{$errors->first('receiver')}}</p>
                                    @else
                                        <p class="jm_error fl"></p>
                                    @endif
                                </div>
                                <div class="item clearfix">
                                    <span class="item-label f-lh36"><i>*</i>手机号码</span>
                                    <input type="text" value="{{old('phone')}}" name="phone" class="item-input item-input-mobile submit_val" placeholder="手机号码" autocomplete="off">
                                    @if($errors->has('phone'))
                                        <p class="jm_error fl">{{$errors->first('phone')}}</p>
                                    @else
                                        <p class="jm_error fl"></p>
                                    @endif
                                </div>
                                <div class="item-bottom clearfix">
                                    <input class="item-submit submit_add" type="submit" value="保存新地址"/>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@include('web.layout.footer')
</body>
<script>
    $(function () {
        $('.nav_left .address').addClass('selected');
        var province=$('.title').children().eq(0).html();
        var city=$('.title').children().eq(1).html();
        var area=$('.title').children().eq(2).html();
        $('#address_head').val(province+city+area);
        if ('{{old("area_code") > 0}}') {
            var province_code = '{{old("province_code")}}';
            var province_name = '{{old("province_name")}}';
            var city_code = '{{old("city_code")}}';
            var city_name = '{{old("city_name")}}';
            var area_code = '{{old("area_code")}}';
            var area_name = '{{old("area_name")}}';
            $('#address_head').val(province_name+city_name+area_name);

            var address_con = '<span class="select-item" data-count="province" data-code="' + province_code + '">' + province_name + '</span>/<span class="select-item" data-count="city" data-code="' + city_code + '">' + city_name + '</span>/<span class="select-item" data-count="district" data-code="' + area_code + '">' + area_name + '</span>';
            $('.city-picker-span .placeholder').hide().next('.title').html(address_con).show();
        }

//        alert(province);
    })
</script>
</html>